package com.example.neo4j.controller;

import com.example.neo4j.pojo.util.ResponseInfo;
import com.example.neo4j.service.HobbyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Controller
public class HobbyController {

    @Autowired
    private HobbyService hobbyService;

    @GetMapping("/hobby/search")
    @ResponseBody
    public ResponseInfo search(@RequestParam("hname") String hname) {
        return hobbyService.search(hname);
    }

    @PostMapping("/hobby/addhobby")
    @ResponseBody
    public ResponseInfo addHobby(@RequestParam("hname") String hname, @RequestParam("htype") String htype) {
        return hobbyService.addHobby(hname, htype);
    }

    @GetMapping("/hobby/getall")
    public String getAll(HttpServletRequest request, Map<String, Object> map) {
        return hobbyService.getAll(request, map);
    }
}
